import request from '@/utils/request'

// 1.获取所有角色列表
export const getRoleList = pageInfo => {
  return request({
    url: '/sys/role',
    method: 'get',
    params: pageInfo
  })
}

/**
 * 根据id删除角色
 */
export const deleteRole = id => {
  return request({
    url: `/sys/role/${id}`,
    method: 'delete'
  })
}

/**
 * 新增角色
 */
export const addRole = data => {
  return request({
    url: `/sys/role`,
    method: 'post',
    data
  })
}

/**
 * 根据id获取角色详细信息
 */
export const getRoleDetail = id => {
  return request({
    url: `sys/role/${id}`,
    method: 'get'
  })
}

/**
 * 修改角色
 */
export const editRole = data => {
  return request({
    url: `sys/role/${data.id}`,
    method: 'put',
    data
  })
}

/**
 * 根据id查询企业
 */
export const getCompanyInfo = id => {
  return request({
    url: `/company/${id}`,
    method: 'get'
  })
}

/**
 * 给角色分配权限
 */
export const assignPermisson = data => {
  return request({
    url: `/sys/role/assignPrem`,
    method: 'put',
    data
  })
}
